package com.gmall.order.test;

public class ServiceImplWrapper implements IService {

    IService service;

    ServiceImplWrapper(IService service){
        this.service = service;
    }

    private String cache="";
    @Override
    public String test1() {
        System.out.println("新增的功能");
        if(cache.equals("")){
            this.cache = service.test1();
        }
        return this.cache;
    }

    public static void main(String[] args) {
        IService service1 = new ServiceImpl();
        IService service2 = new ServiceImplWrapper(service1);
        System.out.println(service2.test1());
        System.out.println(service2.test1());
        System.out.println(service2.test1());
    }

}
